<template>
  <a-form-item :name="props.formNamePath" :label="formItem.label" :rules="[formItem.rule]" :extra="formItem.extra"
    :style="{ marginLeft: formItem.marginLeft + 'px' }"
    :class="formItem.associated ? 'form-a-radio-group_associated' : 'form-a-number-input'">
    <div class="abstrct">
      <span class="beforeText" v-if="formItem.beforeText">{{ formItem.beforeText }}</span>
      <a-textarea :disabled="formItem.disabled" @change="changeText" v-model:value="formItem.value" :rows="5"
        :placeholder="formItem.placeholder" :show-count="formItem.showCount" :maxlength="formItem.maxCount" allow-clear>
      </a-textarea>
      <span class="afterText" v-if="formItem.afterText">{{ formItem.afterText }}</span>
      <a class="getcontent" v-if="formItem.getContent" @click="getSummary">{{ formItem.getContent }}</a>
    </div>
    <div class="help-msg" v-if="formItem.helpMsg">
      {{ formItem.helpMsg }}
    </div>
  </a-form-item>
</template>

<script lang="ts" setup>
import { ref, reactive, watch, computed } from "vue"
import { dataSourceType } from "@/type.d";
import { useColumnItem } from '@/components/draggable/hooks/useColumnModel';
//props
const props = defineProps({
  formItem: {
    type: Object,
    default: {} as dataSourceType
  },
  formNamePath: []
})

const emit = defineEmits(['changeText', 'getSummary'])

const formItem: any = ref(props.formItem as any);
useColumnItem(computed(() => props.formItem), formItem)
const changeText = (e: any) => {
  console.log(e, 'sss');
  emit('changeText', e.target.value)
}
const getSummary = () => {
  emit('getSummary', props.formNamePath);
}
</script>

<style lang="less" scoped>
.help-msg {
  margin-top: 8px;
  font-size: 12px;
  font-family: PingFang SC-Regular, PingFang SC;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.45);
  line-height: 20px;
}

.abstrct {
  position: relative;

  .getcontent {
    position: absolute;
    bottom: 24px;
    right: 10px;
    z-index: 1;
    margin-top: 8px;
    font-size: 14px;
    font-family: PingFang SC-Regular, PingFang SC;
    font-weight: 400;
    color: #1F6DED;
    line-height: 22px;
    cursor: pointer;
    background-color: #fff;
  }
}
</style>